package com.hellobike.haxing.config;

import com.hellobike.haxing.common.vo.Result;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * shiro 无权限返回
 */
@Slf4j
@ControllerAdvice
public class NoPermissionException {
    @ResponseBody
    @ExceptionHandler(UnauthorizedException.class)
    public Result<?> handleShiroException(Exception ex) {
        log.error("==无权限操作===",ex.getCause());
        return Result.error("没有权限，请联系admin管理员授权");
    }
}
